import { showToast as vantToast,showLoadingToast as vantLoading,closeToast  as closeVantToast , showDialog }    from "vant";
import mitter from "./mitt";
const showToast = (msg?:string)=>{
    vantToast(msg);
}

const closeToast = ()=>{
    closeVantToast();
}


const closeToast_back = ()=>{
    
    mitter.emit('closeLoading','')
}
const showLoading = (msg?:string)=>{
    if(!msg) msg = '加载中...'
    
    vantLoading({
        message: msg,
        forbidClick: true,
        duration:0
    });
}

const showLoading_backup = (msg?:string)=>{
  
    if(!msg) msg = '加载中...'
     mitter.emit('showLoading',msg);
}


const showAlert = (msg?:string)=>{
    return new Promise((resolve,reject)=>{
        showDialog({
            message:msg,
         }).then(() => {
            resolve('');
        });
    });
}

const showLoading2 = ()=>{
    
}
export default {
    showToast,closeToast,showLoading,showAlert,showLoading2
} 